from sys_value import *
from sys_value import user_info  # user_info = {}


# user_info=内存地址
# print(user_info)

def read_data():
    try:
        with open('data_txt', 'r', encoding='utf-8') as f:
            data = f.readline()
            set_user_info(eval(data))
    except Exception:
        save_data()


# 1.读取数据到user_info字典
# 2.添加数据到user_info字典
# 3.把添加了数据的user_info字典写入文件

def save_data():
    with open('data_txt', 'w', encoding='utf-8') as f:
        user_info = get_user_info()
        f.write(str(user_info))
